package com.itheima;

import java.util.Random;

public class PlayingCards {
    public static void main(String[] args) {
        // 创建一个扑克牌
        String [] colors = {"♥", "♠", "♣", "♦"};
        String [] numbers = {"A", "J", "Q", "K", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
        String [] cards = new String[54];  //动态数组
        int index = 0;
        for (int i = 0;i<colors.length;i++){
            String color = colors[i];
            for (int j = 0;j<numbers.length;j++){
                String number = numbers[j];
                //card = number + color
                String card = number + color;
                //将card放入到cards数组中
//                cards[index] = card;
//                index++;
                cards[index++] = card;
            }
        }
        cards[52] = "小王";
        cards[53] = "大王";
        System.out.println("____________________________");
        for (String s : cards) {
            System.out.println(s + "\t");
        }

        shuffle(cards);
        System.out.println("____________________________");
        for (String card : cards) {
            System.out.println(card + "\t");
        }
    }

    public static void shuffle(String [] cards){
        Random random  = new Random();
        for (int i = 0;i<cards.length;i++){
            int randomIndex = random.nextInt(cards.length);
            String temp = cards[i];
            cards[i] = cards[randomIndex];
            cards[randomIndex] = temp;
        }
    }
}
